<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>请他人代录资料</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm.min.css">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm-extend.min.css">
    <link rel="stylesheet" href="/static/wx/css/reset.css">
    <link rel="stylesheet" href="/static/wx/css/main.css">
    <link rel="stylesheet" href="/static/wx/css/public_main.css">
    <link rel="stylesheet" href="/static/wx/css/select.css">
</head>

<body>
    <div class="page-group">
        <div class="page page-current" id="repfile">
            <!-- 主内容 -->
            <div class="content">
                <div class="bs-box">
                    <div class="bs-box-title red size-m">
                        保单险种
                    </div>
                    <div class="bs-box-content">
                        <div class="bs-box-inner">
                            <div class="bs-box-content-item">
                                <p class="size-m">保单号</p>
                                <div>
                                    <input class="size-m" type="text" placeholder="请填写保单号" name="report_num" value="{$Think.get.report_num | default = ''}" onkeyup="value=value.replace(/[\u4e00-\u9fa5]/ig,'')"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item">
                                <p class="size-m">报案号</p>
                                <div>
                                    <input class="size-m" type="text" placeholder="请填写报案号" name="policy_num" value="{$Think.get.policy_num | default = ''}" onkeyup="value=value.replace(/[\u4e00-\u9fa5]/ig,'')"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item width-link size-m demo">
                                <div>出险险种</div>
                                <div>
                                    <input placeholder="请选择险种" id="insurance_type"  value="" readonly="readonly"/>
                                </div>
                            </div>
                            <div class="fs-dropdown hidden" id="demo">
                                <div class="fs-options">
                                    <!--!empty($Think.get.insurance_type) &&-->

                                    {volist name="list" id="vo"}
                                    <div class="fs-option {if !empty($insurance_name) && in_array($vo.it_id,$insurance_name)} selected{/if}" data-value="{$vo.it_id}" data-index="{$vo.it_id}">
                                        <span class="fs-checkbox"><i></i></span>
                                        <div class="fs-option-label">{$vo.it_name}</div>
                                    </div>
                                    {/volist}
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="bs-box">
                    <div class="bs-box-title red size-m flex">
                        <div>代录人</div>
                        <div class="select-rep-record"  id="selectRecordera">选择代录人</div>
                    </div>
                    <div class="bs-box-content">
                        <div class="bs-box-inner">
                            <div class="bs-box-content-item">
                                <p class="size-m">代录人姓名</p>
                                <div>
                                    <!--value="" readonly=""-->
                                    <input class="size-m" type="text" placeholder="请填写代录人姓名"   readonly="readonly" name="dai" value="{$info.username | default = ''}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item">
                                <p class="size-m">联系方式</p>
                                <div>
                                    <input class="size-m" type="text" placeholder="请填写代录人手机号"  readonly="readonly"  value="{$info.mobile | default = ''}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item width-link size-m">
                                <div>代录人类型</div>
                                <div>
                                    <input placeholder=""   readonly="readonly"  value="{$info.recoder_name | default = ''}"/>
                                </div>
                            </div>
                            <!--<div class="bs-box-content-item width-link size-m">-->
                                <!--<div>选择代录人</div>-->
                                <!--<div>-->
                                    <!--<input placeholder="请选择选择代录人"  readonly="readonly"  id="selectRecorder"/>-->
                                <!--</div>-->
                            <!--</div>-->
                            <div class="bs-box-content-item width-link size-m">
                                <div>请在</div>
                                <div>
                                    <input placeholder="请选择时间"  id="date" value="{$Think.get.end_at | default = ''}" />
                                </div>
                                <div>前录入递交</div>
                            </div>
                        </div>
                        <input type="hidden" value="{$info.ui_id | default = ''}" name ='recordor_id'>
                    </div>
                </div>
                <div class="my-btn" style="margin-top: 1rem;">
                    <span class="active">确认</span>
                </div>
                <p class="text-c size-m margin-t grey">确认后，将短信通知代录人</p>
            </div>
        </div>
    </div>
    <script type='text/javascript' src='/static/wx/lib/sui/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm-extend.min.js' charset='utf-8'></script>
    <script type='text/javascript' src="/static/wx/lib/vue/vue.min.js"></script>
    <script>
        var myDiv = $("#demo");
        $(function () {
            var str = [];
            var typeArr = new Object();
            var myDate = new Date();
            var year = myDate.getFullYear();//获取年
            var month = myDate.getMonth()+1;////获取月
            var day = myDate.getDate();//获取日
            if (month < 10) month = "0" + month;
            if (day < 10) day = "0" + day;
            var time = year+"-"+month+"-"+day;
            $("#date").calendar({
                value: [time]
            });
            $(document).on('touchend','.demo',function(event) {
                if($("#demo").css('display') === 'block'){
                    $("#demo").css({'display':'none'})
                }else{
                    $("#demo").css({'display':'block'})

                }

                $(document).on("click",
                    function() { //对document绑定一个影藏Div方法
                        $(myDiv).hide()
                    });

                event.stopPropagation(); //阻止事件向上冒泡
            });
            $('.fs-option').click(function(event){
                if(!$(this).hasClass('selected')){
                    $(this).addClass('selected')
                }else{
                    $(this).removeClass('selected')
                }
                event.stopPropagation()
            });
            $(document).on('click', '#selectRecordera', function () {
                var policy_num = $("input[ name='policy_num']").val();
                var report_num = $("input[ name='report_num']").val();
              //  var insurance_type = $("#insurance_type").val();
                var end_at = $("#date").val();
                var str='';
                $("#demo  .selected").each(function(index){
                    var b=$(this).attr('data-value');
                    str+=b+',';
                })
                location.href="{:url('insurer/selectOtherList')}?policy_num="+policy_num+"&report_num="+report_num+"&insurance_type="+ str.substring(0,str.length-1)+"&end_at="+end_at;

            });
            $(document).on('click', '.my-btn', function () {

                var policy_num = $("input[ name='policy_num']").val();
                var report_num = $("input[ name='report_num']").val();
                var insurance_type = $(myDiv).find('.selected');
                var dai = $("input[ name='dai']").val();
                var end_at = $("#date").val();
                var recordor_id = $("input[ name='recordor_id']").val();

                if (report_num.length == 0) {
                    $.alert('请填写保单号');
                    return;
                }
                if (policy_num.length == 0) {
                    $.alert('请填写报案号');
                    return;
                }
                if (insurance_type.length ==0) {
                    $.alert('请选择出险险种');
                    return;
                }
                var str = '';
                $("#demo  .selected").each(function(index){
                    var b=$(this).attr('data-value');
                    str+=b+',';
                })
                if (dai.length ==0) {
                    $.alert('请选择代录人');
                    return;
                }
                if (end_at.length ==0) {
                    $.alert('请选择截止时间');
                    return;
                }
                $.ajax({
                    type: 'POST',
                    url: "{:url('insurer/otherInsurer')}",
                    data: {
                        'policy_num':policy_num,
                        'report_num': report_num,
                        'insurance_type': str.substring(0,str.length-1),
                        'end_at': end_at,
                        'recordor_id': recordor_id,
                    },
                    dataType: 'json',
                    success: function (Json) {
                        if (Json.code == 200) {
                            $.alert('保存成功');
                            location.href="{:url('index/index')}";
                        } else {
                            $.alert(Json.msg);
                        }
                    }
                });
            });

        });
    </script>
</body>

</html>